package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by windo on 2015/11/24.
 */
public class GetVerifyCodeTask extends CouponHttpBaseTask {
    private String mPhone;
    private String mType;
    public  GetVerifyCodeTask(String phone , String type){
        super(TaskType.SEND_PHONE_CODE_TASK);
        mPhone = phone;
        mType = type;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS, null);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if(mPhase == TASK_PHASE_INIT){
            CouponHttpRequest request = new CouponHttpRequest(RequestType.SEND_PHONE_CODE_REQUEST);
            JSONObject json = new JSONObject();
            json.put("phoneNum",mPhone);
            json.put("type" , mType);
            request.setData(json.toString());
            request.setApiNo(ApiNo.SEND_PHONE_CODE);
            addRequest(request);
        }
    }
}
